package cn.zhp.controller;

import cn.zhp.entity.Result;
import cn.zhp.service.WorkOrderService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

@RestController
@RequestMapping("manager/work")
public class WorkOrderController {

    @Autowired
    WorkOrderService service;

    @RequestMapping("")
    public ModelAndView index(){
        return new ModelAndView("/work/admin/index");
    }

    @RequestMapping("toDetail")
    public ModelAndView toDetail(){
        return new ModelAndView("/work/work-detail");
    }

    @RequestMapping("selectPage/{pageNum}/{size}")
    public Result selectPage(@PathVariable("pageNum")int pageNum, @PathVariable("size")int size,@RequestBody Map<String,Object> params){
        PageInfo pageInfo = service.selectPage(pageNum, size,params);
        return new Result(true,null,pageInfo);
    }

    @RequestMapping("selectDetail/{id}")
    public Result selectDetail(@PathVariable("id") long id){
        return new Result(true,null,service.selectDetail(id));
    }

}
